package com.zhibang.config.security;

import com.alibaba.fastjson2.JSON;
import com.zhibang.util.RedisUtil;
import com.zhibang.util.Result;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;


/**
 * @author: ly
 * @date: 2025-03-24 09:38
 * 注销处理类
 */
@Component
public class LogoutHandler implements org.springframework.security.web.authentication.logout.LogoutHandler {
    @Resource
    RedisUtil redisUtil;
    @SneakyThrows
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        String token = request.getHeader("token");
        redisUtil.delete("token:" + token);
    }
}
